package com.tarena.lbs.basic.web.repository.impl;

import com.tarena.lbs.basic.web.mapper.DictMapper;
import com.tarena.lbs.basic.web.repository.DictRepository;
import com.tarena.lbs.common.basic.converter.DictConverter;
import com.tarena.lbs.pojo.basic.bo.DictBO;
import com.tarena.lbs.pojo.basic.dos.DictDO;
import com.tarena.lbs.pojo.basic.query.DictQuery;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class DictRepositoryImpl implements DictRepository {

    @Autowired
    private DictMapper dictMapper;

    @Autowired
    private DictConverter dictConverter;

    @Override
    public void insert(DictDO dictDO) {
        dictMapper.insert(dictDO);
    }

    @Override
    public DictBO detail(Integer id) {
        DictDO dictDO = dictMapper.selectByPrimaryKey(id);
        return dictConverter.do2bo(dictDO);
    }

    @Override
    public void update(DictDO record) {
        dictMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public void delete(Integer id) {
        dictMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<DictDO> selectByCondition(DictQuery dictQuery) {
        List<DictDO> dictDOS = dictMapper.selectByCondition(dictQuery);
        return dictDOS;
    }

    @Override
    public DictBO selectBOByCondition(DictQuery dictQuery) {
        DictDO dictDO = dictMapper.selectBOByCondition(dictQuery);
        return dictConverter.do2bo(dictDO);
    }


}
